lease->flags &= ~OAF_BOUND;
- if (!(lease->flags & OAF_STATIC) || lease->lease_cfg->ipv4.s_addr != lease->ipv4.s_addr) {
+ if (!lease->lease_cfg || lease->lease_cfg->ipv4.s_addr != lease->ipv4.s_addr) {
memset(lease->hwaddr, 0, sizeof(lease->hwaddr));
lease->valid_until = now + 3600; /* Block address for 1h */
} else {
return NULL;
/* Old lease, but with an address that is out-of-scope? */
- if (lease && ((lease->ipv4.s_addr & iface->dhcpv4_own_ip.netmask) !=
- (iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_own_ip.netmask)) &&
- !(lease->flags & OAF_STATIC)) {
+ if (lease && !lease->lease_cfg &&
+ ((lease->ipv4.s_addr & iface->dhcpv4_own_ip.netmask) !=
+ (iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_own_ip.netmask))) {
/* Try to reassign to an address that is in-scope */
avl_delete(&iface->dhcpv4_leases, &lease->iface_avl);
lease->ipv4.s_addr = INADDR_ANY;
}
if (lease_cfg) {
- lease->flags |= OAF_STATIC;
-
if (lease_cfg->hostname) {
lease->hostname = strdup(lease_cfg->hostname);
lease->hostname_valid = true;
break;
}
- if ((!(lease->flags & OAF_STATIC) || !lease->hostname) && req_hostname_len > 0) {
+ if (req_hostname_len > 0 && (!lease->lease_cfg || !lease->lease_cfg->hostname)) {
char *new_name = realloc(lease->hostname, req_hostname_len + 1);
if (new_name) {
lease->hostname = new_name;
assigned = assign_na(iface, a);
if (lease_cfg && assigned) {
- a->flags |= OAF_STATIC;
-
if (lease_cfg->hostname) {
a->hostname = strdup(lease_cfg->hostname);
a->hostname_valid = true;
((hdr->msg_type == DHCPV6_MSG_SOLICIT && rapid_commit) ||
hdr->msg_type == DHCPV6_MSG_REQUEST ||
hdr->msg_type == DHCPV6_MSG_REBIND)) {
- if ((!(a->flags & OAF_STATIC) || !a->hostname) && hostname_len > 0) {
+ if (hostname_len > 0 && (!a->lease_cfg || !a->lease_cfg->hostname)) {
char *tmp = realloc(a->hostname, hostname_len + 1);
if (tmp) {
a->hostname = tmp;
} else if ((a->flags & OAF_DHCPV6_NA) && hdr->msg_type == DHCPV6_MSG_DECLINE) {
a->flags &= ~OAF_BOUND;
- if (!(a->flags & OAF_STATIC) || a->lease_cfg->hostid != a->assigned_host_id) {
+ if (!a->lease_cfg || a->lease_cfg->hostid != a->assigned_host_id) {
memset(a->duid, 0, a->duid_len);
a->valid_until = now + 3600; /* Block address for 1h */
} else
enum odhcpd_assignment_flags {
OAF_TENTATIVE = (1 << 0),
OAF_BOUND = (1 << 1),
- OAF_STATIC = (1 << 2),
- OAF_DHCPV6_NA = (1 << 3),
- OAF_DHCPV6_PD = (1 << 4),
+ OAF_DHCPV6_NA = (1 << 2),
+ OAF_DHCPV6_PD = (1 << 3),
};
/* 2-byte type + 128-byte DUID, RFC8415, §11.1 */
if (c->flags & OAF_BOUND)
blobmsg_add_string(&b, NULL, "bound");
- if (c->flags & OAF_STATIC)
+ if (c->lease_cfg)
blobmsg_add_string(&b, NULL, "static");
if (!c->hostname_valid)
if (a->flags & OAF_BOUND)
blobmsg_add_string(&b, NULL, "bound");
- if (a->flags & OAF_STATIC)
+ if (a->lease_cfg)
blobmsg_add_string(&b, NULL, "static");
blobmsg_close_array(&b, m);